from apps import db
from datetime import datetime as dt
class Resume(db.Model):
    __tablename__ = 'resume'
    
    id = db.Column(db.BigInteger, primary_key=True, autoincrement=True, nullable=False)
    run_id = db.Column(db.String(64), nullable=True, comment='分析编号R')
    resume_id = db.Column(db.String(64), nullable=True, comment='重分析编号T')
    resume_create_time = db.Column(db.DateTime, nullable=True, comment='重分析提交时间')
    resume_complete_time = db.Column(db.DateTime, nullable=True, comment='重分析完成时间')
    resume_status = db.Column(db.String(64), nullable=True, comment='重分析状态')
    resume_trace_file = db.Column(db.String(64), nullable=True, comment='重分析监控结果')
    username = db.Column(db.String(64), nullable=True, comment='用户姓名')
    
    def to_dict(self):
        result = {}
        for c in self.__table__.columns:
            value = getattr(self, c.name)
            if isinstance(value, dt.datetime):
                value = value.strftime('%Y-%m-%d %H:%M:%S')
            elif isinstance(value, dt.date):
                value = value.strftime('%Y-%m-%d')
            result[c.name] = value
        return result